<?php 
  error_reporting(E_ALL^E_NOTICE); //取消警告显示
  header('Content-type:application/json');
  date_default_timezone_set("Asia/Shanghai");
  include $_SERVER['DOCUMENT_ROOT']."/common/fun.php";
  include "../conn.php";//https

  $userid = get_post_para('userid',true);
  $deviceid = get_post_para('deviceid',true);
  $moduleid = get_post_para('moduleid',true);
  $type = get_post_para('type',true);
  $name = get_post_para('name',true);

  // 判断用户是否存在
  check_userid($userid,$con);
    
  $sql_update = "UPDATE device_$type set name='$name' where userid='$userid' and deviceid='$deviceid' and moduleid='$moduleid'";
  $res_update = mysqli_query($con,$sql_update);
  if ($res_update)   
  {
      $myArray["resault"] = 'success';
  } 
  else{
      $myArray["msg"]=mysqli_error($con);
      $myArray["resault"] = 'fail';
  }           

  // mysqli_close($con);
  // print_r($myArray); 
  $json = json_encode($myArray,JSON_UNESCAPED_UNICODE);
  echo $json;
?>
